<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>乐热评-因为热爱所以快乐</title>
    <link rel="stylesheet" href="../layui/css/layui.css">
    <link rel="stylesheet" href="../css/global.css">
    <link rel="stylesheet" href="../css/comment.css">
    <script src="../js/aes.js"></script>


</head>
<body class="mbg">

<!-- 你的HTML代码 -->
<div class="layui-header header header-doc ">
    <div class="layui-main pbg">
        <a class="logo" href="../index.html"><img src="../img/logo.png"/>
        </a>
        <ul class="layui-nav layui-layout-left" lay-filter="">
            <li class="layui-nav-item "><a href="../index.html">首页</a></li>
            <li class="layui-nav-item "><a href="../search.html">搜索</a></li>

            <li class="layui-nav-item"><a href="../event.html">动态</a></li>
            <li class="layui-nav-item layui-layout-right layui-this">
                <a href="javascript:;">我的</a>
                <dl class="layui-nav-child">
                    <dd><a href="../my/my.html">个人中心</a></dd>
                    <dd><a href="../my/message.html">留言消息</a></dd>
                    <dd><a href="../my/setting.html#password">修改密码</a></dd>
                    <dd><a href="../my/friends.html">我的关注</a></dd>
                    <dd><a class='logout'>退出</a></dd>
                </dl>
            </li>
        </ul>
    </div>
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</div>


<div class="layui-main pbg">


    <div class="layui-row">
        <div class="layui-col-xs6 layui-col-md12">

            <div class="p-prf">
                <dl class="m-proifo f-cb" id="head-box">
                    <dt class="f-pr" id="ava">
                        <img class="head"
                             src="">
                        <div class="btm"><a href="setting.html#head-icon" class="upload">更换头像</a></div>
                    </dt>
                    <dd>
                        <div class="name f-cb">
                            <div class="f-cb">
                                <h2 id="j-name-wrap" class="wrap f-fl f-cb ">
                                    <span class="tit f-ff2 s-fc0 f-thide"></span>
                                </h2>
                            </div>
                        </div>
                        <ul class="data f-cb ws16">
                            <li><i class="layui-icon"></i></li>
                            <!--男&#xe662; 女&#xe661;-->
                            <li></li>
                            <li></li>
                        </ul>


                        <div class="clearfix ">
                            <div class="inf layui-form-label float_left">个性签名：</div>
                            <div class="inf">&nbsp;</div>

                            <div class="inf layui-form-label float_left">邮箱：</div>
                            <div class="inf">&nbsp;</div>
                        </div>


                    </dd>
                </dl>

            </div>

            <div class="layui-row">
                <div class="layui-col-md2">
                    <ul class="hf-con-block" lay-filter="test">
                        <li class=" tab-block"><a class="ws18 float_right this" href="my.html"> 动态</a></li>
                        <li class=" tab-block"><a class="ws18 float_right" href="../my/friends.html"> 关注</a></li>
                        <li class=" tab-block"><a class="ws18 float_right" href="../my/message.html"><i
                                class="layui-icon">&#xe623;</i> 留言</a></li>
                        <li class=" tab-block"><a class="ws18 float_right" href="../my/setting.html"> 设置</a></li>
                    </ul>
                </div>
                <div class="layui-col-md9">
                    <div class="f-show"></div>
                    <div id="page" class="layui-fluid layui-col-md-offset3"></div>
                </div>

            </div>

        </div>

    </div>
    <div class="footer">
        &copy;Copyright 2018 乐热评<br>
        感谢：<a>Layui</a>,<a>Bootstrap</a>,<a>网易云</a>,<a>QQ音乐</a>,<a>酷我音乐</a>...<br>
        联系我们：<a href="mailto:amoxuk@aliyun.com">amoxuk#aliyun.com(#换成@)</a>
    </div>


</div>

<script type="text/javascript" src="../js/jquery-1.12.0.min.js"></script>
<script src="../js/jquery.session.js"></script>

<script src="../layui/layui.js"></script>
<script src="../js/top.js"></script>
<script src="../js/zone.js"></script>
<script src="../js/user.js"></script>

<script>
    //注意：导航 依赖 element 模块，否则无法进行功能性操作
    layui.use('element', function () {
        var element = layui.element;
    });
    console.log();
    page(getHashStringArgs()['!offset'] ? getHashStringArgs()['!offset'] : 1);

    function page(pidx) {
        layui.use(['laypage'], function () {
            var laypage = layui.laypage;
            //开启HASH
            $.ajax({
                url: "/msg?offset=" + (pidx - 1) * 10 + "&limit=" + 10
                , type: "get"
                , success: function (res) {
                    if (res.status === 0) {
                        if ( res.count === 0) {
                            $('.f-show').html("<p style='text-align:center;-ms-text-align-last: center;text-align-last: center;'>"+
                               "没有可显示的消息"
                                +"</p>");
                            return false;
                        }
                        var dom = $('.f-show');
                        dom.html("");
                        $("#page").html("");
                        res.data.forEach(function (message) {
                            dom.append(
                                "<div class=\"comment-show-con clearfix\">" +
                                "<div class=\"comment-show-con-img pull-left\">" +
                                "<img src=\"" + message.sendUser.icons + "\" alt=\"\">" +
                                "</div>" +
                                "<div class=\"f-list pull-left clearfix\">" +
                                "<div class=\"pl-text clearfix\">" +
                                "<a href= "+zone(message.suid)+" class=\"f-name\">" + message.sendUser.nickname + "</a>" +
                                " <span style=\"margin-right: 4px\">To</span>" +
                                "<img class='icon-sm' " +
                                "src=\""+message.receiveUser.icons+"\" alt=\"\">" +
                                "<a href="+zone(message.ruid)+" class=\"f-name\">"+message.receiveUser.nickname+"</a>"+
                                ":" +
                                "</div>" +
                                "<div class=\"date-dz\">" +
                                "<span class=\"f-note pull-left comment-time\">留言：" + message.content + "</span>" +
                                "<div class=\"date-dz-right pull-right comment-pl-block\">" +
                                "<a class=\"f-opt time\">" + new Date(message.ctime).time() + "</a>" +
                                "<span class=\"pull-left date-dz-line\">&nbsp;</span>" +
                                "<a href=\"javascript:;\" class=\"f-opt send\" data-id='" + message.suid + "'>回复</a>"
                                + "<span class=\"pull-left date-dz-line\">|</span>" +
                                "<a href=\"javascript:;\" class=\"f-opt delete-msg\" data-id='" + message.mid + "'>删除</a>" +
                                "<span class=\"pull-left date-dz-line\">|</span>" +
                                "<a href="+zone(message.suid)+" class=\"f-opt zone\">TA的空间</a>" +
                                "</div>" +
                                "</div>" +
                                "<div class=\"hf-list-con\"></div>" +
                                "</div>" +
                                "</div>"
                            );
                        });

                        laypage.render({
                            elem: 'page'
                            , count: res.count //数据总数，从服务端得到
                            , limit: 10
                            , groups: 4 /*	连续出现的页码个数	Number	5*/
                            , curr: pidx /*必须加这个，否则分页不会走*/
                            , hash: 'offset'
                            , jump: function (obj, first) {
                                //obj包含了当前分页的所有参数，比如：
                                /*console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
                                console.log(obj.limit); //得到每页显示的条数*/
                                if (!first) {
                                    page(obj.curr);
                                    return false;
                                }
                            }
                        });
                    }
                    else {
                        $('.f-show').html("<p style='text-align:center;-ms-text-align-last: center;text-align-last: center;'>" +
                            res.msg+
                            "</p>");
                    }
                }
                , error: function (res) {
                    layer.alert("错误码：" + res.status);
                    $('.f-show').html("<p style='text-align:center;-ms-text-align-last: center;text-align-last: center;'>Opoos,错误码：" + res.status+"</p>");
                }
            });


        });
    }
</script>
</body>
</html>